package com.easyspringboot.bean;

import com.easyspringboot.utils.PropertiesUtils;

/**
 * @Author xiaoyi
 * @Version 1.0
 * @ClassName Constants
 * @Time 17:13
 */
public class Constants {
    public static String AUTHOR_COMMENT;//作者注释
    public static Boolean IGNORE_TABLE_PREFIX;//是否忽略表前缀
    public static String SUFFIX_BEAN_QUERY;//是否在bean后面添加参数
    public static String SUFFIX_BEAN_QUERY_FUZZY;//参数模糊搜索后缀
    public static String SUFFIX_BEAN_QUERY_TIME_START;//参数日期起
    public static String SUFFIX_BEAN_QUERY_TIME_END;//参数日期止

    public  static String DB_DRIVER_NAME;
    public  static String DB_URL;
    public  static String DB_USERNAME;
    public  static String DB_PASSWORD;


    //mapper后缀
    public static String SUFFIX_BEAN_MAPPERS;//mapper后缀
    //Service后缀
    public static String SUFFIX_BEAN_SERVICE;//Service后缀
    //Service实现类后缀
    public static String SUFFIX_BEAN_SERVICE_IMPL;//Service实现类后缀
    //Controller后缀
    public static String SUFFIX_BEAN_CONTROLLER;//Controller后缀
    //exception后缀
    public static String SUFFIX_BEAN_EXCEPTION;//exception后缀

    public static String PATH_BASE;//生成文件的基础路径
    //需要忽略的属性
    public static String IGNORE_BEAN_TOJSON_FIELD;
    public static String IGNORE_BEAN_TOJSON_EXPRESSION;
    public static String IGNORE_BEAN_TOJSON_CLASS;
    //日期序列化，反序列化格式
    public static String BEAN_DATE_FORMAT_EXPRESSION;
    public static String BEAN_DATE_FORMAT_CLASS;

    public static String BEAN_DATE_UNFORMAT_EXPRESSION;//反序列化格式
    public static String BEAN_DATE_UNFORMAT_CLASS;


    public static String PATH_JAVA = "java";//生成java的路径
    public static String PATH_RESOURCES = "resources";//生成resources的路径
    public static String PATH_PO;//生成po的路径
    public static String PATH_QUERY;//生成query的路径
    public static String PATH_RESOURCE;//生成resource的路径
    public static String PATH_UTILS;//生成utils的路径
    public static String PATH_ENUM;//生成enum的路径
    public static String PATH_MAPPER;//生成mapper的路径
    public static String PATH_MAPPER_XML;//生成mapper.xml的路径
    public static String PATH_SERVICE;//生成service的路径
    public static String PATH_SERVICE_IMPL;//生成serviceImpl的路径
    public static String PATH_VO;//生成vo的路径
    public static String PATH_CONTROLLER;//生成controller的路径
    public static String PATH_EXCEPTION;//生成exception的路径
    public static String PATH_RUNAPPLICATION;//生成RunApplication的路径

    //包
    public static String PACKAGE_BASE;//生成文件的基础包名

    public static String PACKAGE_CONTROLLER;//生成controller的包名
    public static String PACKAGE_PO;//生成po的包名
    public static String PACKAGE_QUERY;//生成query的包名
    public static String PACKAGE_UTILS;//生成utils的包名

    public static String PACKAGE_MAPPER;//生成mapper的包名

    public static String PACKAGE_ENUM;//生成enum的包名
    public static String PACKAGE_SERVICE;//生成service的包名
    public static String PACKAGE_SERVICE_IMPL;//生成serviceImpl的包名
    public static String PACKAGE_EXCEPTION;//生成exception的包名
    public static String PACKAGE_VO;

    static {
        AUTHOR_COMMENT = PropertiesUtils.getProperties("author.comment");

        //需要忽略的属性
        IGNORE_BEAN_TOJSON_FIELD = PropertiesUtils.getProperties("ignore.bean.tojson.filed");
        IGNORE_BEAN_TOJSON_EXPRESSION = PropertiesUtils.getProperties("ignore.bean.tojson.expression");
        IGNORE_BEAN_TOJSON_CLASS = PropertiesUtils.getProperties("ignore.bean.tojson.class");
        //日期序列化，反序列化格式
        BEAN_DATE_FORMAT_EXPRESSION = PropertiesUtils.getProperties("bean.date.format.expression");
        BEAN_DATE_FORMAT_CLASS = PropertiesUtils.getProperties("bean.date.format.class");

        BEAN_DATE_UNFORMAT_EXPRESSION = PropertiesUtils.getProperties("bean.date.unformat.expression");
        BEAN_DATE_UNFORMAT_CLASS = PropertiesUtils.getProperties("bean.date.unformat.class");

        DB_DRIVER_NAME = PropertiesUtils.getProperties("db.driver.name");
        DB_URL = PropertiesUtils.getProperties("db.url");
        DB_USERNAME = PropertiesUtils.getProperties("db.username");
        DB_PASSWORD = PropertiesUtils.getProperties("db.password");


        //是否忽略表前缀
        IGNORE_TABLE_PREFIX = Boolean.valueOf(PropertiesUtils.getProperties("ignore.table.prefix"));
        //是否在bean后面添加参数
        SUFFIX_BEAN_QUERY = PropertiesUtils.getProperties("suffix.bean.param");
        //参数模糊搜索后缀
        SUFFIX_BEAN_QUERY_FUZZY = PropertiesUtils.getProperties("suffix.bean.param.fuzzy");
        //参数日期起
        SUFFIX_BEAN_QUERY_TIME_START = PropertiesUtils.getProperties("suffix.bean.param.time.start");
        //参数日期止
        SUFFIX_BEAN_QUERY_TIME_END = PropertiesUtils.getProperties("suffix.bean.param.time.end");
        //mapper后缀
        SUFFIX_BEAN_MAPPERS = PropertiesUtils.getProperties("suffix.bean.mappers");
        //Service后缀
        SUFFIX_BEAN_SERVICE = PropertiesUtils.getProperties("suffix.bean.service");
        //Service实现类后缀
        SUFFIX_BEAN_SERVICE_IMPL = PropertiesUtils.getProperties("suffix.bean.service.impl");
        //Controller后缀
        SUFFIX_BEAN_CONTROLLER = PropertiesUtils.getProperties("suffix.bean.controller");
        //生成文件的基础包名
        PACKAGE_BASE = PropertiesUtils.getProperties("package.base");
        //生成controller的包名
        PACKAGE_CONTROLLER = PACKAGE_BASE + "." + PropertiesUtils.getProperties("package.controller");
        //生成exception的包名
        PACKAGE_EXCEPTION = PACKAGE_BASE + "." + PropertiesUtils.getProperties("package.exception");
        //生成po的包名
        PACKAGE_PO = PACKAGE_BASE + "." + PropertiesUtils.getProperties("package.po");
        //生成文件的基础路径
        PACKAGE_UTILS = PACKAGE_BASE + "." + PropertiesUtils.getProperties("package.utils");
        //生成enum的包名
        PACKAGE_ENUM = PACKAGE_BASE + "." + PropertiesUtils.getProperties("package.enum");
        //生成query的包名
        PACKAGE_QUERY = PACKAGE_BASE + "." + PropertiesUtils.getProperties("package.query");
        //生成mapper的包名
        PACKAGE_MAPPER = PACKAGE_BASE + "." + PropertiesUtils.getProperties("package.mapper");
        //生成service的包名
        PACKAGE_SERVICE = PACKAGE_BASE + "." + PropertiesUtils.getProperties("package.service");
        //生成serviceImpl的包名
        PACKAGE_SERVICE_IMPL = PACKAGE_SERVICE + "." + PropertiesUtils.getProperties("package.service.impl");
        //生成vo的包名
        PACKAGE_VO = PACKAGE_BASE + "." + PropertiesUtils.getProperties("package.vo");

        //生成文件的基础路径
        PATH_BASE = PropertiesUtils.getProperties("path.base");
        PATH_BASE = PATH_BASE + PATH_JAVA;

        //生成java的路径
        PATH_VO = PATH_BASE + "/" + PACKAGE_VO.replace(".", "/");//生成vo的路径
        PATH_PO = PATH_BASE + "/" + PACKAGE_PO.replace(".", "/");//生成po的路径
        PATH_UTILS = PATH_BASE + "/" + PACKAGE_UTILS.replace(".", "/");//生成utils的路径
        PATH_ENUM = PATH_BASE + "/" + PACKAGE_ENUM.replace(".", "/");//生成enum的路径
        PATH_QUERY = PATH_BASE + "/" + PACKAGE_QUERY.replace(".", "/");//生成query的路径
        PATH_MAPPER = PATH_BASE + "/" + PACKAGE_MAPPER.replace(".", "/");//生成mapper的路径
        PATH_MAPPER_XML = PATH_BASE.replace(PATH_JAVA, PATH_RESOURCES) + "/" + PACKAGE_MAPPER.replace(".", "/");//生成mapper.xml的路径
        PATH_SERVICE = PATH_BASE + "/" + PACKAGE_SERVICE.replace(".", "/");//生成service的路径
        PATH_SERVICE_IMPL = PATH_BASE + "/" + PACKAGE_SERVICE_IMPL.replace(".", "/");//生成serviceImpl的路径
        PATH_CONTROLLER = PATH_BASE + "/" + PACKAGE_CONTROLLER.replace(".", "/");//生成controller的路径
        PATH_EXCEPTION = PATH_BASE + "/" + PACKAGE_EXCEPTION.replace(".", "/");//生成exception的路径
        PATH_RUNAPPLICATION = PATH_BASE + "/" + PACKAGE_BASE.replace(".", "/");//生成runApplication的路径
        PATH_RESOURCE=PATH_BASE.replace(PATH_JAVA, PATH_RESOURCES);//生成resource的路径
    }

    public static final String[] SQL_DATA_TIME_TYPES = new String[]{"datetime", "timestamp", "time"};
    public static final String[] SQL_DATE_TYPES = new String[]{"date"};
    public static final String[] SQL_INTEGER_TYPES = new String[]{"int", "tinyint", "smallint", "mediumint", "integer"};
    public static final String[] SQL_LONG_TYPES = new String[]{"bigint"};
    public static final String[] SQL_DECIMAL_TYPES = new String[]{"decimal"};
    public static final String[] SQL_DOUBLE_TYPES = new String[]{"double"};
    public static final String[] SQL_FLOAT_TYPES = new String[]{"float"};
    public static final String[] SQL_STRING_TYPES = new String[]{"varchar", "char", "text", "tinytext", "mediumtext", "longtext"};


//    public static void main(String[] args) {
//        System.out.println(PATH_PO);
//    }
}
